package 线程池.作业;


import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.CopyOnWriteArraySet;

public class 编写程序添加查询学生 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        lo:
        while (true) {
            System.out.println("欢迎来到此程序");
            System.out.println("   ↓↓↓     ");
            System.out.println("添加学生按①,查询学生按②,结束按〇");
            Integer lu = sc.nextInt();
            switch (lu) {
                case 1:
//                    System.out.println("+++");
                    tianjia();
                    break;
                case 2:
//                    System.out.println("xxxx");
                    BufferedReader br = new BufferedReader(new FileReader("src/线程池/作业/xuesheng.txt"));
                    String lien;
                    while ((lien=br.readLine())!=null){
                        System.out.println(lien);
                    }
                        br.close();
                    break;
                case 0:
                    break lo;
            }

        }


    }

    static void tianjia() throws IOException {
        System.out.println("请输入学生姓名,年龄,住处");
        String s = new Scanner(System.in).nextLine();

        BufferedWriter bw = new BufferedWriter(new FileWriter("src/线程池/作业/xuesheng.txt",true));
            bw.write(s);
            bw.newLine();
            bw.close();
        }

    }
